<template>
  <div class="wrap">
    <div>下面是</div>
    <ul class="lister">
      <li
        v-for="(item,index) in content"
        :id="index"
        @click="trigger($event,item.uid)"
        :key="index"
      >{{item.master}}</li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [],
      defaultProps: {
        children: "children",
        label: "label",
      },
      uid: null,
      content: null,
      addCount:null
    };
  },
  created() {
    // console.log("页面打开");
    this.uid = localStorage.getItem("uid");
    //   alert(this.uid)
    // alert(this.uid)
    this.$nextTick(() => {
      this.tree(this.uid);
    });
  },
  mounted() {},
  methods: {
    handleNodeClick(data) {
      console.log(data.label);
    },
    //树
    tree(uid) {
      //   var uid = localStorage.getItem("uid");
      if (uid != null) {
        this.axios({
          method: "post",
          url: "/api/office/queryOfficeList",
          data: { uid: uid },
        }).then((res) => {
          //   console.log(res);
          this.content = res.data.data;
          // console.log("内容是");
          // console.log(this.content);
        });
      } else {
        alert("您的uid是空的");
      }
    },
    tree2(uid) {
      if (uid != null) {
        this.axios({
          method: "post",
          url: "/api/office/queryOfficeList",
          data: { uid: uid },
        }).then((res) => {
          this.addCount = res.data.data;
        });
      } else {
        alert("您的uid是空的");
      }
    },
    trigger(e, uid) {
      // alert(uid);
      console.log(e.target.id);
      var cc = e.target.id;
      // console.log("数运行");
      this.tree(uid);

      var idName = document.getElementById(cc);
      var div = document.createElement("div");
      // console.log("下面是tree2")
      this.tree2(uid)

      div.innerHTML = "asdfasdf";
      e.target.appendChild(div);

      // div.innerHTML = "asdffasdf"
      // idName.appendChild(div)
    },
  },
};
</script>

<style scoped>
.wrap {
  width: 200px;
  height: 300px;
  background: white;
  border: 1px solid blue;
  position: absolute;
  z-index: 99999999;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  overflow-y: scroll;
}
.lister > li {
  font-size: 16px;
}
</style>